package com.ruoyi.project.wx.service.impl;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.bootdo.PageHelperUtils;
import com.ruoyi.project.wx.dao.CmsSlideDao;
import com.ruoyi.project.wx.dao.GoodsNineDao;
import com.ruoyi.project.wx.dao.MemberUserDao;
import com.ruoyi.project.wx.domain.CmsSlideDO;
import com.ruoyi.project.wx.domain.GoodsNineDO;
import com.ruoyi.project.wx.service.GoodsNineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class GoodsNineServiceImpl implements GoodsNineService {
	@Autowired
	private GoodsNineDao goodsNineDao;
	@Autowired
	private CmsSlideDao cmsSlideDao;
	@Autowired
	private MemberUserDao memberUserDao;
	
	@Override
	public GoodsNineDO get(String id){
		return goodsNineDao.get(id);
	}
	
	@Override
	public List<GoodsNineDO> list(Map<String, Object> map){
		return goodsNineDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return goodsNineDao.count(map);
	}
	
	@Override
	public int save(GoodsNineDO goodsNine){
		return goodsNineDao.save(goodsNine);
	}
	
	@Override
	public int update(GoodsNineDO goodsNine){
		return goodsNineDao.update(goodsNine);
	}
	
	@Override
	public int remove(String id){
		return goodsNineDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return goodsNineDao.batchRemove(ids);
	}

	@Override
	public Map<String,Object> nine() {
		Map<String,Object> map = new HashMap<String,Object>();
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("type", "2");
		List<CmsSlideDO> imgList = cmsSlideDao.queryAll(params);
		if (imgList.size() == 0) {
			map.put("img","0");
		} else {
			map.put("img",imgList.get(0));
		}
		params.put("pan","0");
		List<Map<String,Object>> goodsList = goodsNineDao.getNineGoodsList(params);
		map.put("goodsList",goodsList);
		return map;
	}

	/*app查询列表*/
	@Override
	public PageInfo<Map<String,Object>> getNineGoodsList(Map<String, Object> paramMap) {
		PageHelperUtils.page(paramMap);
		List<Map<String,Object>> list =goodsNineDao.getNineGoodsList(paramMap);
		/*if(paramMap.containsKey("userId")&&StringUtils.isNotBlank(paramMap.get("userId").toString())&&list.size()>0){
			MemberUserDO memberUserDO = memberUserDao.get(paramMap.get("userId").toString());
			for (Map<String, Object> map : list) {
				if(memberUserDO.getLevel()=='A'){
					map.put("newPrice", map.get("price_a").toString());
				}else if (memberUserDO.getLevel()=='B'){
					map.put("newPrice", map.get("price_b").toString());
				}else if (memberUserDO.getLevel()=='C'){
					map.put("newPrice", map.get("price_c").toString());
				}
			}
		}*/
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	/*后台查询9.9列表*/
	@Override
	public List<Map<String,Object>> getNineList(Map<String, Object> map) {
		return goodsNineDao.getNineList(map);
	}

	@Override
	public int getNineListCount(Map<String, Object> map) {
		return goodsNineDao.getNineListCount(map);
	}


	
}
